class Solution(object):
    def findMaxAverage(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: float
        """
        t = sum(nums[: k])
        n = len(nums)
        max_val = t / k
        for i in range(0, n - k):
            t = t + nums[i + k] - nums[i]
            max_val = max(t / k, max_val)
        return max_val